import ApiService from "../utils/apiService.ts";
import { useConfig } from "./D8dConfigProvider.tsx";
import { useMemo } from "react";

// 自定义 Hook 来封装请求逻辑
export const useApiService = () => {
  const { appConfig, token } = useConfig();
  const apiBaseUrl = appConfig.apiBaseUrl;

  // 创建一个ApiService实例
  const apiService = useMemo(() => {
    return new ApiService(apiBaseUrl, token);
  }, [apiBaseUrl, token]);

  return apiService;
};
